package com.appbee.songs.client;

import javax.inject.Inject;
import javax.inject.Singleton;

import com.appbee.core.client.modular.IModulRegistry;
import com.appbee.core.client.modular.impl.ActivityModul;
import com.appbee.songs.client.activity.SongsTableActivity;
import com.appbee.songs.client.presenter.SongEditActivity;
import com.google.gwt.inject.client.AsyncProvider;

@Singleton
public class SongActivityModul extends ActivityModul
{
	private static final String PLAYLIST = "playlist";
	private final AsyncProvider<SongEditActivity> songEditProvider;
	private String songActivityId;
	private final IModulRegistry registry;

	@Inject
	public SongActivityModul(	IModulRegistry registry,
								AsyncProvider<SongsTableActivity> songProvider,
								AsyncProvider<SongEditActivity> songEditProvider)
	{
		this.registry = registry;
		super.setDefaultActivty(songProvider);
		this.songEditProvider = songEditProvider;

	}

	public void register()
	{
		this.register("track");
	}

	public void register(String songEditActivityId)
	{
		this.songActivityId = songEditActivityId;
		super.register(songEditActivityId, songEditProvider);
		registry.register(PLAYLIST, this);
	}

	public String getSongsActivityId()
	{
		return currentNavItem.getPath();
	}

	public String getSongActivityId()
	{
		return getSongsActivityId() + "_" + songActivityId;
	}

	@Override
	public String getName()
	{
		return "Playlist";
	}

	@Override
	public String getId()
	{
		return PLAYLIST;
	}

}
